import 'package:flutter/material.dart';
import 'package:we_chat_app/const.dart';
import 'package:we_chat_app/discover/discover_child_page.dart';

class MyCell extends StatefulWidget {
  final String image;
  final String title;
  final String subTitle;
  final String subImage;

  const MyCell(
      {required this.image,
      required this.title,
      required this.subTitle,
      required this.subImage});

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _MyCellState();
  }



}


class _MyCellState extends State<MyCell> {

  Color _color = Colors.white;

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return GestureDetector(
      child: Container(
        color: _color,
        padding: const EdgeInsets.all(6),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            // left
            Container(
                height: 40,
                width: 100,
                padding: const EdgeInsets.all(10),
                child: Row(
                  children: [
                    Image(
                      image: AssetImage(
                        widget.image,
                      ),
                      width: 20,
                    ),
                    const SizedBox(width: 15),
                    Text(widget.title)
                  ],
                )),
            // right
            Container(
                height: 40,
                width: 100,
                padding: const EdgeInsets.all(10),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(widget.subTitle),
                    const SizedBox(width: 10),
                    widget.subImage != '' ? Image.asset(widget.subImage) : Container(),
                    const Icon(Icons.chevron_right,color: Colors.grey,)
                  ],
                ))
          ],
        ),
      ),
      onTap: (){
        Navigator.of(context).push(
            MaterialPageRoute(builder: (BuildContext context) {
              return DiscoverChildPage(widget.title);
            })
        );
        setState(() {
          _color = themeColor;
        });
      },
      onTapDown: (TapDownDetails details){
        setState(() {
          _color = contextColor;
        });
      },
    );
  }
}
